<?php
$model = new Administrator_Model_User();
$title = 'Thay đổi thông tin thành viên';
$button = '<button class="save button" name="btsave" value="btsave" type="submit"></button>';
$button .= '<button class="back button" name="btback" value="btback" type="submit"></button>';
$button .= '<button class="option button" name="btoption" value="btoption" type="submit"></button>';
?>
<form method="post" enctype="multipart/form-data">
	<div class="nav">
		<div class="navbutton">
		<?php echo $button;?>
	</div>
	</div>
	<div class="sheet">
		<div class="mana-title"><?php echo $title?></div>
		<div class="intro">
			<div class="form">
				<div class="small edit">
<?php
$info['type'] = ''; 
$username = '';
$name = '';
$type = '';
$email ='';
$phone ='';
$birthday ='';
$gender ='';
$address ='';
$birthday ='';
$image ='';
if($this->id !=''){
	$info = $model->GetUserInfo($this->id);
	$username = $info['username'];
	$name = $info['name'];
	$email = $info['email'];
	$image = '<img style="float:right;width:120px;width:110px;border:1px solid #DDD;padding:5px;box-shadow:0 0 2px #DFDFDF;" src="'.$model->ImageUrl('user', $info['image']).'">';
	$phone = $info['phone'];
	$type = $info['type'];
	$birthday =$info['birthday'];
	$gender =$info['gender'];
	$address =$info['address'];
}
else {
	$info = $model->GetUserInfo($this->ulogin->id);
	$username = $info['username'];
	$name = $info['name'];
	$email = $info['email'];
	$image = '<img style="float:right;width:120px;width:110px;border:1px solid #DDD;padding:5px;box-shadow:0 0 2px #DFDFDF;" src="'.$model->ImageUrl('user', $info['image']).'">';
	$phone = $info['phone'];
	$type = $info['type'];
	$birthday =$info['birthday'];
	$gender =$info['gender'];
	$address =$info['address'];
}
?>
					<div class="element">
						<div class="eleft">Tên đăng nhập :</div>
						<div class="eright">
							<input type="text" name="username" value="<?php echo $username?>">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Mật khẩu :</div>
						<div class="eright">
							<input type="password" name="password" value="">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Tên thật :</div>
						<div class="eright">
							<input type="text" name="realname" value="<?php echo $name?>">
						</div>
					</div>
						<div class="element">
						<div class="eleft">Ngày sinh :</div>
						<div class="eright">
							<input type="text" name="birthday" value="<?php echo $birthday?>">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Giới tính :</div>
						<div class="eright">
							<?php if($gender == '0') {?>
								<label for="boy">Nam<input type="radio" name="gioitinh" value="0" checked="checked"></label>
								<label for="girl">Nữ<input type="radio" name="gioitinh" value="1"></label>
								<label for="not identified">Không xác định<input type="radio" name="gioitinh" value="2"></label>
							<?php ;}elseif($gender =='1') { ?>
								<label for="boy">Nam<input type="radio" name="gioitinh" value="0" ></label>
								<label for="girl">Nữ<input type="radio" name="gioitinh" value="1" checked="checked"></label>
								<label for="not identified">Không xác định<input type="radio" name="gioitinh" value="2"></label>
							<?php ;}elseif($gender =='2') { ?>
								<label for="boy">Nam<input type="radio" name="gioitinh" value="0" ></label>
								<label for="girl">Nữ<input type="radio" name="gioitinh" value="1" checked="checked"></label>
								<label for="not identified">Không xác định<input type="radio" name="gioitinh" value="2" checked="checked"></label>
							<?php 
								;
							}?>
						</div>
					</div>
					<div class="element">
						<div class="eleft">Địa chỉ :</div>
						<div class="eright">
							<input type="text" name="address" value="<?php echo $address?>">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Email :</div>
						<div class="eright">
							<input type="text" name="email" value="<?php echo $email?>">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Hình ảnh đại diện :</div>
						<div class="eright">
							<?php echo $image?>
						</div>
					</div>
					<div class="element">
						<div class="eleft">Chọn hình khác:</div>
						<div class="eright">
							<input type="file" name="image">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Số điện thoại :</div>
						<div class="eright">
							<input type="text" name="phone" value="<?php echo $phone?>">
						</div>
					</div>
					<div class="element">
						<div class="eleft">Phân quyền :</div>
						<div class="eright">
						<?php 
						foreach ($model->GetAllUser_Type() as $value) {
							$selected = '';if($type == $value['id']) $selected = ' checked = "checked"';						
							if($value['id'] ==1){
								if($this->utype==1)echo '<label for="'.$value['id'].'">'.$value['name'].'<input id="'.$value['id'].'"'.$selected.' type="radio" value="'.$value['id'].'" name="type"/></label>';
							}
							else echo '<label for="'.$value['id'].'">'.$value['name'].'<input id="'.$value['id'].'"'.$selected.' type="radio" value="'.$value['id'].'" name="type"/></label>';
						}
						
						?>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>